using Godot;

namespace PlayerState
{
public partial class Jump : Node,StateNode
{    
    public Player player;
    public PlayerAnimaVfx animaVfx;

    public override void _Ready()
    {
        player = GetNode<Player>("/root/Main/Player");
        animaVfx = player.GetNode<PlayerAnimaVfx>("AnimaVfx");
    }
    
    public void OnEnter()
    {
        GetNode<AnimatedSprite2D>("../../AnimaPlayer").Animation = "jump";
        animaVfx.OnJump(player.GlobalPosition);

        GetNode<AudioStreamPlayer2D>("Music").Play();
    }
  
    public void OnExit()
    {                        
    }

    public void OnUpdate(float delta)
    {                        
        if(player.Health<=0)
            player.SwitchTo("Dead");        
        else if(player.Velocity.Y>0)
            player.SwitchTo("Fall");
    }

}
}
